package cc.uncarbon.module.appapi.service;

import cc.uncarbon.module.appapi.mapper.StoreMapper;
import cc.uncarbon.module.appapi.model.vo.StoreVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yanrumiao.entity.StoreEntity;
import com.yanrumiao.util.ConvertUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.sql.Time;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

@RequiredArgsConstructor
@Service
@Slf4j
public class StoreService {
    private final StoreMapper storeMapper;


    public List<StoreVO> getStoreList() {
        List<StoreEntity> list = storeMapper.selectList(new QueryWrapper<StoreEntity>().lambda()
                .eq(StoreEntity::getStatus, 1));
        List<StoreVO> vo = new ArrayList<>(list.size());
        DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");


        list.forEach(store -> {
            vo.add(ConvertUtil.boToVo(store, StoreVO.class));
        });
        return vo;
    }

    public StoreEntity getStoreById(Long storeId) {
        return storeMapper.selectById(storeId);
    }
}
